class Solution {
public:
    int jump(vector<int>& nums) {
        //区间dp
        int left=0,right=0;
        int step=0;
        int maxi=0;
        while(right<=(int)nums.size()-2)
        {
            for(int i=left;i<=right;i++)
            {
                maxi=max(maxi,i+nums[i]);
            }
            left=right+1;
            right=maxi;
            step++;
        }
        return step;

    }
};